'-------------------
'Josh Haywood I'll Do It Myself XYZ Probe Macro
'To probe Y-
'https://www.youtube.com/illdoitmyself
'Note: This script is designed for metric units e.g. mm
'-------------------
Dim ProbeDiameter As Double, FeedCurrent, YPlateWidth As Double, YPosCurrent As Double, YZeroOffset As Double

YPlateWidth = getoemdro(1152) 'Accurately measuerd plate wall width on Y Axis
ProbeDiameter = GetOemDro(1000) 'Get Probe diameter
FeedCurrent = GetOemDRO(818) 'Get the current settings

If GetOemLed (825) <> 0 Then 'Check to see if the probe is already grounded or faulty
  Code "(Probe plate is grounded, check connection and try again)"
Else
  YPosCurrent = GetDro(1) 'Get current position
  Code "F100" 'slow feed rate to 100 mm/min

  Code "G31 Y" & (PosCurrent + 25) 'probe 25mm to the Front
  While GetOemLed (825) = 0
    Sleep(1)
  Wend

  Sleep(250) 'Wait for DRO to update

  YZeroOffset = ((1 * YPlateWidth) + (ProbeDiameter / 2)) 'Calculate X Zero
  Call SetDro (1, YZeroOffset) 'Set the Dro

  Sleep(250) 'Wait for DRO to update

  Code "G0 Y" & (GetDro(1) + Abs(10)) & " F400" 'Move off the plate 10mm
  While IsMoving()
  Wend

  Code "(Y Axis Zeroed for Platewall:" & YPlateWidth & " Tool Diameter:" & ProbeDiameter & ")"
  Code "F" & FeedCurrent 'Restore Feedrate
End If
 

